//
//  NavigationView.swift
//  Box
//
//  Created by mn on 2025/3/30.
//


import UIKit
import SnapKit

class NavigationView: UIView {
    
    let backButton: UIButton = {
        let button = UIButton(type: .custom)
        button.setImage(UIImage.arrowLeft, for: .normal)
        button.layer.cornerRadius = 12
        button.backgroundColor = .black.withAlphaComponent(0.15)
        return button
    }()
    let rightButton: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitle("暂不登录", for: .normal)
        button.setTitleColor(.init(hex: "#B3F832"), for: .normal)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        return button
    }()
    func addRightButton(){
        addSubview(rightButton)
        rightButton.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-16)
            make.centerY.equalToSuperview()
        }
    }
    private let titleLabel: UILabel = {
        let label = UILabel()
        label.textColor = .fromHex("#333333")
        label.font = UIFont.systemFont(ofSize: 18)
        label.textAlignment = .center
        return label
    }()
    var title: String?{
        didSet{
            titleLabel.text = title
        }
    }
    init() {
        super.init(frame: .zero)
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        addSubview(backButton)
        addSubview(titleLabel)

        backButton.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(16)
            make.centerY.equalToSuperview()
            make.width.height.equalTo(40)
        }

        titleLabel.snp.makeConstraints { make in
            make.center.equalToSuperview()
        }
    }
     
}
